import { keyBy } from 'lodash-es';
import { GetSmartDeviceModelDpSchema } from '@ray-js/panel-sdk';

export const lampSchema = [
  {
    attr: 646,
    canTrigger: true,
    code: 'switch_led',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_power',
    id: 20,
    mode: 'rw',
    name: '开关',
    property: {
      type: 'bool',
    },
    type: 'obj',
  },
  {
    attr: 640,
    canTrigger: true,
    code: 'work_mode',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_mode',
    id: 21,
    mode: 'rw',
    name: '模式',
    property: {
      range: ['white', 'colour', 'scene', 'music'],
      type: 'enum',
    },
    type: 'obj',
  },
  {
    attr: 512,
    canTrigger: true,
    code: 'colour_data',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-yanse',
    id: 24,
    mode: 'rw',
    name: '彩光',
    property: {
      type: 'string',
      maxlen: 255,
    },
    type: 'obj',
  },
  {
    attr: 640,
    canTrigger: true,
    code: 'countdown',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_time2',
    id: 26,
    mode: 'rw',
    name: '倒计时剩余时间',
    property: {
      unit: 's',
      min: 0,
      max: 86400,
      scale: 0,
      step: 1,
      type: 'value',
    },
    type: 'obj',
  },
  {
    attr: 640,
    canTrigger: true,
    code: 'music_data',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_mic',
    id: 27,
    mode: 'wr',
    name: '音乐灯',
    property: {
      type: 'string',
      maxlen: 255,
    },
    type: 'obj',
  },
  {
    attr: 512,
    canTrigger: true,
    code: 'light_length',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-setting',
    id: 46,
    mode: 'ro',
    name: '灯带长度',
    property: {
      unit: 'cm',
      min: 1,
      max: 10000,
      scale: 0,
      step: 1,
      type: 'value',
    },
    type: 'obj',
  },
  {
    attr: 512,
    canTrigger: true,
    code: 'light_pixel',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-setting',
    id: 47,
    mode: 'ro',
    name: '灯带点数',
    property: {
      min: 1,
      max: 1024,
      scale: 0,
      step: 1,
      type: 'value',
    },
    type: 'obj',
  },
  {
    attr: 640,
    canTrigger: true,
    code: 'dreamlight_scene_mode',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_mode',
    id: 51,
    mode: 'rw',
    name: '幻彩情景',
    property: {
      type: 'raw',
      maxlen: 128,
    },
    type: 'raw',
  },
  {
    attr: 128,
    canTrigger: true,
    code: 'dreamlightmic_music_data',
    defaultRecommend: false,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_mic',
    id: 52,
    mode: 'rw',
    name: '幻彩本地音乐律动',
    property: {
      type: 'raw',
      maxlen: 128,
    },
    type: 'raw',
  },
  {
    attr: 640,
    canTrigger: true,
    code: 'lightpixel_number_set',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-gongneng',
    id: 53,
    mode: 'rw',
    name: '点数/长度设置',
    property: {
      min: 1,
      max: 1000,
      scale: 0,
      step: 1,
      type: 'value',
    },
    type: 'obj',
  },
  {
    attr: 512,
    canTrigger: true,
    code: 'paint_colour_data',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_circle',
    id: 61,
    mode: 'rw',
    name: '涂抹调色',
    type: 'raw',
  },
  {
    attr: 512,
    canTrigger: true,
    code: 'rtc_timer',
    defaultRecommend: true,
    editPermission: false,
    executable: true,
    extContent: '',
    iconname: 'icon-dp_circle',
    id: 61,
    mode: 'rw',
    name: '本地定时',
    type: 'raw',
  },
] as const;

export const lampSchemaMap = keyBy(lampSchema, 'code') as GetSmartDeviceModelDpSchema<
  typeof lampSchema
>;
